From: wangzhaohui Date: Wed, 24 Jun 2026 01:00:47 +0000 (+0800) Subject: repo: Fix validation for min-free-space-percent config option X-Git-Tag: archive/raspbian/2026.2-1+rpi1^2~9^2^2~4^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3aa6dacf0938dabf3cb43b6c36d1def25d6dfbc1;p=ostree.git repo: Fix validation for min-free-space-percent config option Add explicit validation that the string contains only digits before converting to a number. This ensures invalid values are rejected with a clear error message. Fixes: https://github.com/ostreedev/ostree/issues/3274 --- diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index f20611b4..e366cda1 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -3176,6 +3176,14 @@ reload_core_config (OstreeRepo *self, GCancellable *cancellable, GError **error) NULL, &min_free_space_percent_str, error)) return FALSE; + /* Validate that the string contains only digits */ + for (const char *p = min_free_space_percent_str; *p; p++) + { + if (!g_ascii_isdigit (*p)) + return glnx_throw (error, "Invalid min-free-space-percent '%s': must be a number", + min_free_space_percent_str); + } + self->min_free_space_percent = g_ascii_strtoull (min_free_space_percent_str, NULL, 10); if (self->min_free_space_percent > 99) return glnx_throw (error, "Invalid min-free-space-percent '%s'",